package com.fh.binarysearch;

/**
 * T162.寻找峰值
 * @author fuhao
 * @date 2025/10/14 21:57
 */
public class T162FindPeakElement {

    class Solution {
        public int findPeakElement(int[] nums) {
            int left = 0;
            int right = nums.length - 1;

            while (left < right) {
                int mid = left + (right - left) / 2;
                if (nums[mid] < nums[mid + 1]) {
                    // 峰值在右侧
                    left = mid + 1;
                } else {
                    // 峰值在左侧（包括mid）
                    right = mid;
                }
            }
            return left;
        }
    }
}
